#pragma once
#include "ReconstructByKinectCommon.h"
#include "SensorResource.h"

class PatternCalibrationProcess
{
public:
	PatternCalibrationProcess ();
	~PatternCalibrationProcess ();

	void initialize ();
	void clean ();

	void process (std::vector< SensorResource > &sensorReses);

private:

	IplImage *_pattImage;
	IplImage *_pattImageShow;
	glm::vec3 _cornersInWorldSpace[PATT_ROWS * PATT_COLUMNS + PATT_Z_POINTS];
	glm::vec3 _cornersInCamSpace[PATT_ROWS * PATT_COLUMNS + PATT_Z_POINTS];
	SensorResource::PatternCalibrationData *_pData;
	SensorDataInput *_pSensor;

	void _recognizePattern (IplImage *image);
	void _calculateCornersInCameraSpace ();
	glm::mat4 _calculateExtrinsicMatrix ();
	glm::mat4 _calculateTranslation ();
	glm::mat4 _calculateRotation ();
	glm::mat4 _calculateScale ();
	void _getCameraMatrix ();
	void _showResult (IplImage *image, glm::mat4x4 rtsmat);
	glm::mat4 _calculateExtrinsicMatrixCv ();
	glm::mat4 _calculateExtrinsicMatrixBySolveEquation ();
};
